#if !defined(AFX_RawDlg_H__A7EB85C3_1EEA_4FEC_8450_C090219B8619__INCLUDED_)
#define AFX_CRawDlgDlg_H__A7EB85C3_1EEA_4FEC_8450_C090219B8619__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "../client/Util.h"
#include "../client/ClientProfileManager.h"
#include "WinUtil.h"

#include "PropPage.h"
#include "../client/StringTokenizer.h"
#include "LineDlg.h"

class RawProfileDlg : public CDialogImpl<RawProfileDlg>
{
	CEdit ctrlName, ctrlRaw1, ctrlRaw2, ctrlRaw3, ctrlRaw4, ctrlRaw5, ctrlRaw6, ctrlRaw7, ctrlRaw8, ctrlRaw9, ctrlRaw10;

public:
	
	string name;
	string raw1;
	string raw2;
	string raw3;
	string raw4;
	string raw5;
	string raw6;
	string raw7;
	string raw8;
	string raw9;
	string raw10;
	int currentProfileId;
	bool adding;
	RawProfile currentRawProfile;

	enum { IDD = IDD_RAW_PROFILE_DLG };

	BEGIN_MSG_MAP(RawProfileDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
		COMMAND_ID_HANDLER(IDC_NEXT, onNext)
		COMMAND_ID_HANDLER(IDC_BACK, onNext)
	END_MSG_MAP()

	RawProfileDlg() { };

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
		if(wID == IDOK) {
			updateVars();
			if(adding) {
				if (name.empty()) {
					LineDlg dlg;
					dlg.title = STRING(NAME_EMPTY);
					if(dlg.DoModal() == IDOK){
						name = dlg.line;
					}else{
						return 0;
					}				
				}
				RawProfile::List lst = ClientProfileManager::getInstance()->getRawProfiles();
				for(RawProfile::Iter j = lst.begin(); j != lst.end(); ++j) {
					if((*j).getName().compare(name) == 0) {
						LineDlg dlg;
						dlg.line = name += "(2)";
						dlg.title = (name + " " + STRING(C_PROFILE_EXIST));
						if(dlg.DoModal() == IDOK){
							name = dlg.line;
						}else{
							return 0;
						}				
					}
				}
			}
		}
		EndDialog(wID);
		return 0;
	}
	LRESULT onNext(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	void updateControls();
	void getRawProfile();
	void updateVars();
	int itemCount;
};
#endif